import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class Intent2 extends Activity {
    TextView label2;
    Button   btnCallActivity1;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sctiviti2);
        label2 = (TextView)findViewById(R.id.label2);
        btnCallActivity1 = (Button)findViewById(R.id.btnCallActivity1);
        btnCallActivity1.setOnClickListener(new Clicker1());
        Intent myLocalIntent = getIntent();
        Bundle myBundle = myLocalIntent.getExtras();


        String str1 = myBundle.getString("myString1");
        double dob1 = myBundle.getDouble("myDouble1");
        int[]  arr1 = myBundle.getIntArray("myIntArray1");
        

        String strArr  = "{ ";
        int sumIntValues = 0;
        for (int i=0; i<arr1.length; i++) {
        	sumIntValues += arr1[i];
        	strArr += Integer.toString( arr1[i] ) + " ";
        }
        strArr += " }";


        label2.setText("Activity2   (receiving...) \n\n" +
        		       "myString1:   " + str1 + "\n" + 
        		       "myDouble1:   " + Double.toString(dob1) + "\n" + 
        		       "myIntArray1: " + strArr);
                
  
        double someNumber = sumIntValues + dob1;
        myBundle.putString("myReturnedString1", "Adios Android");
        myBundle.putDouble("myReturnedDouble1", someNumber);
        myBundle.putString("myCurrentTime", new Date().toLocaleString() );
        myLocalIntent.putExtras(myBundle);

        setResult(Activity.RESULT_OK, myLocalIntent);
        
    }//onCreate
    
    private class Clicker1 implements OnClickListener {
		public void onClick(View v) {
			finish();			
		} 	
    }

}




import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class MainActivity extends Activity {
	TextView label1,tv;
	
	TextView label1Returned;
	Button btnCallActivity2;
	private final int IPC_ID = 1122;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		tv=(TextView)findViewById(R.id.textView1);
		try {
			setContentView(R.layout.activity_main);
			label1 = (TextView) findViewById(R.id.label1);
			label1Returned = (TextView) findViewById(R.id.label1Returned);
			btnCallActivity2 = (Button) findViewById(R.id.btnCallActivity2);
			btnCallActivity2.setOnClickListener(new Clicker1());
			label1.setText("Activity1   (sending...) \n\n"
					+ "myString1:  Hello Android" + "\n"
					+ "myDouble1:  3.141592     " + "\n"
					+ "myIntArray: {1 2 3} ");
		} catch (Exception e) {
			Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG)
					.show();
		}
	}// onCreate
	public void Vasile(View v)
	{
		tv=(TextView)findViewById(R.id.textView1);
	tv.setText("Salut!");
	}
	private class Clicker1 implements OnClickListener {
		public void onClick(View v) {
			try {
				Intent myIntentA1A2 = new Intent(MainActivity.this,
						Intent2.class);

				Bundle myData = new Bundle();
				myData.putString("myString1", "Hello Android");
				myData.putDouble("myDouble1", 3.141592);
				int[] myLittleArray = { 1, 2, 3 };
				myData.putIntArray("myIntArray1", myLittleArray);

				myIntentA1A2.putExtras(myData);

				startActivityForResult(myIntentA1A2,IPC_ID);
			} catch (Exception e) {
				Toast.makeText(getBaseContext(), e.getMessage(),
						Toast.LENGTH_LONG).show();
			}
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		try {
			switch (requestCode) {
			case IPC_ID: {
				if (resultCode == Activity.RESULT_OK) {

					Bundle myReturnedData = data.getExtras();
					String myReturnedString1 = myReturnedData
							.getString("myReturnedString1");
					Double myReturnedDouble1 = myReturnedData
							.getDouble("myReturnedDouble1");
					String myReturnedString2 = myReturnedData
							.getString("myCurrentTime");

					label1Returned.setText(myReturnedString1 + "\n"
							+ Double.toString(myReturnedDouble1) + "\n"
							+ myReturnedString2);
				} else {

					label1.setText("Selection CANCELLED!");
				}
				break;
			}
			}
		} catch (Exception e) {
			Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG)
					.show();
		}
	}

}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	android:id="@+id/linLayout"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:background="#ffccffff"
	android:orientation="vertical"
	xmlns:android="http://schemas.android.com/apk/res/android">
	<TextView
		android:id="@+id/caption1"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:background="#ffff3300"
		android:padding="4sp"
		android:text=" Activity1 "
		android:textSize="20px"
		android:textStyle="bold"
		android:textColor="#ff000000">
	</TextView>
	<TextView
		android:id="@+id/widget107"
		android:layout_width="fill_parent"
		android:layout_height="2sp">
	</TextView>
	<TextView
		android:id="@+id/label1"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:background="#ffffffcc"
		android:text="Data to be sent to SubActivity:"
		android:textStyle="bold">
	</TextView>
	<Button
		android:id="@+id/btnCallActivity2"
		android:layout_width="149px"
		android:layout_height="wrap_content"
		android:padding="6sp"
		android:text="Call  Activity2"
		android:textStyle="bold">
	</Button>
	<TextView
		android:id="@+id/label1Returned"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:background="#ffffffcc"
		android:text=" Data returned by Activity2"
		android:textStyle="bold">
	</TextView>

	

	<TextView
	    android:id="@+id/textView1"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:text="MyTextView" />

	<EditText
	    android:id="@+id/editText1"
	    android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:ems="10" 
	    >

	    <requestFocus />
	</EditText>

	<Button
	    android:id="@+id/button1"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:text="MyBut" 
	    android:onClick="Vasile"/>
	
</LinearLayout>





<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffcc"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffff9900"
android:padding="4sp"
android:text=" Activity2"
android:textSize="20px"
android:textStyle="bold"
>
</TextView>
<TextView
android:id="@+id/widget107"
android:layout_width="fill_parent"
android:layout_height="2sp"
>
</TextView>
<TextView
android:id="@+id/label2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffccffff"
android:text="Data Received from Activity1 ..."
android:textStyle="bold"
>
</TextView>
<Button
android:id="@+id/btnCallActivity1"
android:layout_width="149px"
android:layout_height="wrap_content"
android:padding="6sp"
android:text="CallBack  Activity1"
android:textStyle="bold"
>
</Button>
</LinearLayout>





<activity android:name=".Intent2"
     android:label="@string/app_name" >


